﻿using System;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using EmacsLauncher.Properties;

namespace EmacsLauncher
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            string path = Settings.Default.exePath;
            if (path.Equals("."))
            {
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Filter = "可执行文件(*.exe)|*.exe";
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    path=Settings.Default.exePath = dialog.FileName;
                    Settings.Default.Save();
                }
            }

            ProcessStartInfo startInfo=new ProcessStartInfo(path);
            startInfo.WorkingDirectory = Path.GetDirectoryName(path);
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;  //隐藏console窗口
            Process.Start(startInfo);

            /*使用windows api隐藏窗口句柄*/
            //new WinApi().hideConsoleWindow(path);
        }
    }
}
